package com.capt_3;

import java.util.Random;

public class Equation {
//    封装
//    Equation 用来 描述所有的算式
    private int leftNumber,rightNumber,result;
    private char op='+';

    //    产生指定区间的随即整数

    public int getLeftNumber(){
         return leftNumber;
    }

    public void setLeftNumber(int leftNumber) {
        this.leftNumber = leftNumber;
    }

    public int getRightNumber() {
        return rightNumber;
    }

    public void setRightNumber(int rightNumber) {
        this.rightNumber = rightNumber;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public char getOp() {
        return op;
    }

    public void setOp(char op) {
        this.op = op;
    }

    public Equation() {
    }

    public Equation(int leftNumber, int rightNumber, int result, char op) {
        this.leftNumber = leftNumber;
        this.rightNumber = rightNumber;
        this.result = result;
        this.op = op;
    }
    //  拼接算式的字符串
    public String toString(){
        return ""+leftNumber+op+rightNumber+"="+" ";
    }

//    判断在不在某个区间内
    public boolean isBetween(int value,int max,int main){
        return value >= main && value <= main;
    }

    //    产生指定区间的随即整数

    public int getLeftNumbers(int max,int min){
        Random random = new Random();
        return random.nextInt(max-min+1)+min;
    }
//    判断当前算式和其它算式是否相同
    public boolean isEqual(Equation e){
        if(this.getOp()!=e.getOp()){
            return false;
        }else {
            if (this.getLeftNumber()== e.getLeftNumber()&& this.getRightNumber() == e.getRightNumber()){
                return true;
            }else {
                return true;
            }
        }
    }

//    sdd
    public int add(){
        return leftNumber+rightNumber;
    }
//    dub
    public int sub(){
        return leftNumber - rightNumber;
    }

}
